<template>
  <div>
    <el-dialog
      title="提示"
      :visible.sync="dialogVisible"
      width="30%"
      :before-close="handleClose"
    >
      <!--:showClose="false" 关闭x  -->
      <el-form ref="form" :model="form" label-width="80px">
        <el-form-item label="titles">
          <el-input v-model="form.titles"></el-input>
        </el-form-item>
        <el-form-item label="id">
          <el-input v-model="form.id"></el-input>
        </el-form-item>
        <el-form-item label="pid">
          <el-input v-model="form.pid"></el-input>
        </el-form-item>
        <el-form-item>
          <el-button type="primary" @click="onSubmit">立即创建</el-button>
          <el-button @click="dialogVisible = false">取消</el-button>
        </el-form-item>
      </el-form>
    </el-dialog>
  </div>
</template>

<script>
import { postRoutes } from "@/api/setUp";
export default {
  data() {
    return {
      dialogVisible: false,
      form: {},
      bool: true,
    };
  },
  created() {
    console.log(this.dialogStatus, "ppp");
  },
  methods: {
    handleClose() {
      this.dialogVisible = false;
    },
    onSubmit() {
      var length = Object.keys(this.form).length;
      console.log(length);
      this.bool = false;
      if (length == 3) {
        for (let key in this.form) {
          if (this.form[key] == "") {
            this.bool = false;
            return;
          }
        }
        /* 发请求 */
        postRoutes(this.form).then((res) => {
          if (res.code == 200) {
            this.form = {};
            this.$nextTick(() => {
              this.$message({
                message: "上传成功",
                type: "success",
              });
            });
          }
        });

        return;
      }
      this.$message({
        message: "请检查信息是否输入完整",
        type: "error",
      });
    },
  },
};
</script>

<style>
</style>